import fetch from "./axios";

//axios
//如果是GET请求，入参使用params字段
// 如果是POST请求，入参使用data字段

//获取主页的商品列表
export function fetchGoodLists(params){
    return fetch({
        url:'/good/list',
        method:'get',
        params
    })
}
//获取主页的商品列表
export function fetchCatesLists(params){
    return fetch({
        url:'/good/cates',
        method:'get',
        params
    })
}
//获取商品的详情
export function fetchGoodsDetail(params){
    return fetch({
        url:'/good/detail',
        method:'get',
        params
    })
}
//获取登录的接口
export function fetchLogin(data){
    return fetch({
        url:'/user/login',
        method:'post',
        data
    })
}
//获取注册的接口
export function fetchRegis(data){
    return fetch({
        url:'/user/regist',
        method:'post',
        data
    })
}
//添加到购物车的接口
export function fetchAddCarts(data){
    return fetch({
        url:'/cart/add',
        method:'post',
        data
    })
}
//显示到购物车里面的信息
export function fetchCartList(params){
    return fetch({
        url:'/cart/list',
        method:'get',
        params
    })
}
//删除购物车里面的信息
export function fetchDelList(params){
    return fetch({
        url:'/cart/del',
        method:'get',
        params
    })
}
//更新购物车里面的信息
export function fetchUpdate(params){
    return fetch({
        url:'/cart/update',
        method:'get',
        params
    })
}
//提交购物车里面的信息
export function fetchPay(data){
    return fetch({
        url:'/cart/pay',
        method:'post',
        data
    })
}

//导出到原型链上面使用
export default{
    fetchGoodLists,
    fetchCatesLists,
    fetchGoodsDetail,
    fetchLogin,
    fetchRegis,
    fetchAddCarts,
    fetchCartList,
    fetchDelList,
    fetchUpdate,
    fetchPay
}